home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 7: Sunsite / Linux Cubed Series 7 - Sunsite Vol 1.iso / system / emulator / bsvc-1.000 / bsvc-1 / bsvc-1.0.4 / src / Assemblers / 68kasm / asm.h next >
Text File  |  1995-07-26  |  5KB  |  163 lines

  1. /******************************************************************************
  2.  * $Id: asm.h,v 1.1 1994/08/29 23:52:04 bmott Exp $
  3.  ******************************************************************************
  4.  *
  5.  *        ASM.H
  6.  *        Global Definitions for 68000 Assembler
  7.  *
  8.  *      Author: Paul McKee
  9.  *        ECE492    North Carolina State University
  10.  *
  11.  *        Date:    12/13/86
  12.  *
  13.  *   Copyright 1990-1991 North Carolina State University. All Rights Reserved.
  14.  *
  15.  ******************************************************************************
  16.  * $Log: asm.h,v $
  17.  * Revision 1.1  1994/08/29  23:52:04  bmott
  18.  * Initial revision
  19.  *
  20.  *****************************************************************************/
  21.  
  22. /* Status values */
  23.  
  24. /* These status values are 12 bits long with
  25.    a severity code in the upper 4 bits */
  26.  
  27. #define OK         0x00
  28. #define FALSE         0x00
  29. #define TRUE        0xFF
  30.  
  31. /* Severe errors */
  32. #define SEVERE        0x400
  33. #define SYNTAX        0x401
  34. #define INV_OPCODE    0x402
  35. #define INV_ADDR_MODE    0x403
  36. #define LABEL_REQUIRED    0x404
  37. #define PHASE_ERROR    0x405
  38.  
  39. /* Errors */
  40. #define ERROR        0x300
  41. #define UNDEFINED    0x301
  42. #define DIV_BY_ZERO    0x302
  43. #define MULTIPLE_DEFS    0x303
  44. #define REG_MULT_DEFS    0x304
  45. #define REG_LIST_UNDEF    0x305
  46. #define INV_FORWARD_REF    0x306
  47. #define INV_LENGTH    0x307
  48.  
  49. /* Minor errors */
  50. #define MINOR        0x200
  51. #define INV_SIZE_CODE    0x201
  52. #define INV_QUICK_CONST    0x202
  53. #define INV_VECTOR_NUM    0x203
  54. #define INV_BRANCH_DISP 0x204
  55. #define INV_DISP    0x205
  56. #define INV_ABS_ADDRESS    0x206
  57. #define INV_8_BIT_DATA    0x207
  58. #define INV_16_BIT_DATA    0x208
  59. #define ODD_ADDRESS    0x209
  60. #define NOT_REG_LIST    0x20A
  61. #define REG_LIST_SPEC    0x20B
  62. #define INV_SHIFT_COUNT    0x20C
  63.  
  64. /* Warnings */
  65. #define WARNING        0x100
  66. #define ASCII_TOO_BIG    0x101
  67. #define NUMBER_TOO_BIG    0x102
  68. #define INCOMPLETE    0x103
  69.  
  70. #define SEVERITY    0xF00
  71.  
  72. /* The NEWERROR macros updates the error variable var only if the
  73.    new error code is more severe than all previous errors.  Throughout
  74.    ASM this is the standard means of reporting errors. */
  75.  
  76. #define NEWERROR(var, code)    if ((code & SEVERITY) > var) var = code
  77.  
  78.  
  79. /* Symbol table definitions */
  80.  
  81. /* Significant length of a symbol */
  82. #define SIGCHARS 8
  83.  
  84. /* Structure for a symbol table entry */
  85. typedef struct symbolEntry {
  86.     int value;            /* 32-bit value of the symbol */
  87.     struct symbolEntry *next;    /* Pointer to next symbol in linked list */
  88.     char flags;            /* Flags (see below) */
  89.     char name[SIGCHARS+1];        /* Name */
  90.     } symbolDef;
  91.  
  92. /* Flag values for the "flags" field of a symbol */
  93.  
  94. #define BACKREF        0x01    /* Set when the symbol is defined on the 2nd pass */
  95. #define REDEFINABLE    0x02    /* Set for symbols defined by the SET directive */
  96. #define REG_LIST_SYM    0x04    /* Set for symbols defined by the REG directive */
  97.  
  98.  
  99. /* Instruction table definitions */
  100.  
  101. /* Structure to describe one "flavor" of an instruction */
  102.  
  103. typedef struct {
  104.     int source,        /* Bit masks for the legal source...    */
  105.         dest;        /*  and destination addressing modes    */
  106.     char sizes;        /* Bit mask for the legal sizes */
  107.     int (*exec)();        /* Pointer to routine to build the instruction */
  108.     short int bytemask,    /* Skeleton instruction masks for byte size...    */
  109.           wordmask,    /*  word size, ...                */
  110.           longmask;    /*  and long sizes of the instruction        */
  111.     } flavor;
  112.  
  113.  
  114. /* Structure for the instruction table */
  115. typedef struct {
  116.     char *mnemonic;        /* Mnemonic */
  117.     flavor *flavorPtr;    /* Pointer to flavor list */
  118.     char flavorCount;    /* Number of flavors in flavor list */
  119.     char parseFlag;        /* Should assemble() parse the operands? */
  120.     int (*exec)();        /* Routine to be called if parseFlag is FALSE */
  121.     } instruction;
  122.  
  123.  
  124. /* Structure for operand descriptors */
  125. typedef struct {
  126.     int mode;    /* Mode number (see below) */
  127.     int data;    /* Immediate value, displacement, or absolute address */
  128.     char reg;    /* Principal register number (0-7) */
  129.     char index;    /* Index register number (0-7 = D0-D7, 8-15 = A0-A7) */
  130.     char size;    /* Size of index register (WORD or LONG, see below) */
  131.     char backRef;    /* True if data field is known on first pass */
  132.     } opDescriptor;
  133.  
  134.  
  135. /* Addressing mode codes/bitmasks */
  136.  
  137. #define DnDirect    0x00001
  138. #define AnDirect    0x00002
  139. #define AnInd        0x00004
  140. #define AnIndPost    0x00008
  141. #define AnIndPre    0x00010
  142. #define AnIndDisp    0x00020
  143. #define AnIndIndex    0x00040
  144. #define AbsShort    0x00080
  145. #define AbsLong        0x00100
  146. #define PCDisp        0x00200
  147. #define PCIndex        0x00400
  148. #define Immediate    0x00800
  149. #define SRDirect    0x01000
  150. #define CCRDirect    0x02000
  151. #define USPDirect    0x04000
  152. #define SFCDirect    0x08000
  153. #define DFCDirect    0x10000
  154. #define VBRDirect    0x20000
  155.  
  156.  
  157. /* Register and operation size codes/bitmasks */
  158.  
  159. #define BYTE    1
  160. #define WORD    2
  161. #define LONG    4
  162. #define SHORT    8
  163.